package springframework.beans.factory.support;

import springframework.beans.MutablePropertyValues;
import springframework.beans.PropertyValues;

public class RootBeanDefinition extends AbstractBeanDefinition {

    public static final int DEPENDENCY_CHECK_NONE = 0;
    public static final int DEPENDENCY_CHECK_OBJECTS = 1;
    public static final int DEPENDENCY_CHECK_SIMPLE = 2;
    public static final int DEPENDENCY_CHECK_ALL = 3;
    public static final int AUTOWIRE_NO = 0;
    public static final int AUTOWIRE_BY_NAME = 1;
    public static final int AUTOWIRE_BY_TYPE = 2;
    public static final int AUTOWIRE_CONSTRUCTOR = 3;

    private Class beanClass;
    private ConstructorArgumentValues constructorArgumentValues;
    private String[] dependsOn;
    private int dependencyCheck;
    private int autowire;
    private String initMethodName;
    private String destroyMethodName;

    public RootBeanDefinition(Class beanClass, PropertyValues pvs) {
        super(pvs);
        this.beanClass = beanClass;
    }

    public RootBeanDefinition(Class beanClass, PropertyValues pvs, boolean singleton) {
        super(pvs);
        this.beanClass = beanClass;
        setSingleton(singleton);
    }

    public RootBeanDefinition(Class beanClass, ConstructorArgumentValues cargs, PropertyValues pvs) {
        super(pvs);
        this.beanClass = beanClass;
        this.constructorArgumentValues = cargs;

    }

    public RootBeanDefinition(RootBeanDefinition other) {
        super(new MutablePropertyValues(other.getPropertyValues()));
        this.beanClass = other.beanClass;
        this.constructorArgumentValues = other.constructorArgumentValues;
        setSingleton(other.isSingleton());
    }

    public boolean hasConstructorArgumentValues() {
        return this.constructorArgumentValues != null && !this.constructorArgumentValues.isEmpty();
    }


    public String[] getDependsOn() {
        return dependsOn;
    }

    public void setDependsOn(String[] dependsOn) {
        this.dependsOn = dependsOn;
    }

    public int getAutowire() {
        return autowire;
    }

    public void setAutowire(int autowire) {
        this.autowire = autowire;
    }

    public Class getBeanClass() {
        return beanClass;
    }

    public void setBeanClass(Class beanClass) {
        this.beanClass = beanClass;
    }

    public ConstructorArgumentValues getConstructorArgumentValues() {
        return constructorArgumentValues;
    }

    public void setConstructorArgumentValues(ConstructorArgumentValues constructorArgumentValues) {
        this.constructorArgumentValues = constructorArgumentValues;
    }

    public int getDependencyCheck() {
        return dependencyCheck;
    }

    public void setDependencyCheck(int dependencyCheck) {
        this.dependencyCheck = dependencyCheck;
    }

    public String getInitMethodName() {
        return initMethodName;
    }

    public void setInitMethodName(String initMethodName) {
        this.initMethodName = initMethodName;
    }

    public String getDestroyMethodName() {
        return destroyMethodName;
    }

    public void setDestroyMethodName(String destroyMethodName) {
        this.destroyMethodName = destroyMethodName;
    }
}
